package com.colorlight.cloud.complete.entity.po;

import com.colorlight.cloud.complete.entity.enumerate.NetworkChannel;
import com.colorlight.cloud.gateway.api.message.constraint.basics.object.Trans;
import com.colorlight.iot.proto.complete.entity.CompleteEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WifiApInfo implements Trans<WifiApInfo, CompleteEntity.WifiApInfo> {

    /**
     * 热点是否打开，false为关闭
     */
    private Boolean enable;

    /**
     * 设备设置的WIFI AP名称
     */
    private String ssid;

    /**
     * 密码
     */
    private String password;

    /**
     * 网络物理地址（MAC地址）
     */
    private String mac;
    
    private Integer channel;
    private NetworkChannel networkChannel;
    
    
    @Override
    public CompleteEntity.WifiApInfo toProto() {
        CompleteEntity.WifiApInfo.Builder builder = CompleteEntity.WifiApInfo.newBuilder();
        builder.setEnable(this.getEnable());
        builder.setSsid(this.getSsid());
        builder.setPassword(this.getPassword());
        builder.setMac(this.getMac());
        builder.setChannel(this.getChannel());
        //自增字段不映射
        return builder.build();
    }
    
    @Override
    public WifiApInfo formProto(CompleteEntity.WifiApInfo wifiApInfo) {
        this.setEnable(wifiApInfo.getEnable());
        this.setSsid(wifiApInfo.getSsid());
        this.setPassword(wifiApInfo.getPassword());
        this.setMac(wifiApInfo.getMac());
        this.setChannel(wifiApInfo.getChannel());
        this.setNetworkChannel( NetworkChannel.HZ5G.formProto( wifiApInfo.getChannel()));
        return this;
    }
}

